<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微信登录</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }
        body {
            background-color: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            color: #333;
        }
        .login-container {
            background: white;
            border-radius: 4px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            width: 380px;
            padding: 30px;
            text-align: center;
        }
        .logo {
            width: 80px;
            height: 80px;
            margin: 0 auto 20px;
            background-color: #07C160;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .logo i {
            font-size: 40px;
            color: white;
        }
        h2 {
            font-weight: normal;
            margin-bottom: 25px;
            color: #1a1a1a;
        }
        .input-group {
            margin-bottom: 15px;
            position: relative;
        }
        .input-group i {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #999;
        }
        .input-group input {
            width: 100%;
            padding: 12px 15px 12px 40px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
            transition: border-color 0.3s;
        }
        .input-group input:focus {
            border-color: #07C160;
            outline: none;
        }
        .captcha-group {
            display: flex;
            gap: 10px;
            margin-bottom: 15px;
        }
        .captcha-group input {
            flex: 1;
        }
        .captcha-img {
            width: 100px;
            height: 40px;
            background: #f0f0f0;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-style: italic;
            color: #666;
            cursor: pointer;
            user-select: none;
        }
        .login-btn {
            width: 100%;
            padding: 12px;
            background-color: #07C160;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            cursor: pointer;
            margin-top: 10px;
            transition: background-color 0.3s;
        }
        .login-btn:hover {
            background-color: #06ae56;
        }
        .register-btn {
            display: block;
            text-align: center;
            margin-top: 15px;
            color: #07C160;
            text-decoration: none;
            font-size: 14px;
        }
        .footer {
            margin-top: 20px;
            font-size: 12px;
            color: #999;
        }
        .agreement {
            display: flex;
            align-items: center;
            font-size: 13px;
            color: #999;
            margin-top: 15px;
            text-align: left;
        }
        .agreement input {
            margin-right: 5px;
        }
        .agreement a {
            color: #576b95;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="logo">
            <i class="fab fa-weixin"></i>
        </div>
        <h2>微信登录</h2>
        <form id="loginForm">
            <div class="input-group">
                <i class="fas fa-user"></i>
                <label for="username"></label><input type="text" id="username" placeholder="请输入用户名" required>
            </div>
            <div class="input-group">
                <i class="fas fa-lock"></i>
                <label for="password"></label><input type="password" id="password" placeholder="请输入密码" required>
            </div>
            <div class="captcha-group">
                <div class="input-group">
                    <i class="fas fa-shield-alt"></i>
                    <label for="captcha"></label><input type="text" id="captcha" placeholder="请输入验证码" required>
                </div>
                <div class="captcha-img" id="captchaImage">1234</div>
            </div>
            <div class="agreement">
                <input type="checkbox" id="agreeCheck" checked>
                <label for="agreeCheck">我已阅读并同意<a href="#">《服务条款》</a>和<a href="#">《隐私政策》</a></label>
            </div>
            <button type="submit" class="login-btn" onclick="login()">登录</button>
        </form>
        <a href="#" class="register-btn" onclick="register()">注册账号</a>
        <div class="footer">
            <p>版权所有 ©九转苍翎</p>
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script>
        //登录
        function login() {
            $.ajax({
                url: '/user/login',
                type: "post",
                data:{
                    userName:$('#username').val(),
                    password:$('#password').val(),
                },
                success: function (result) {
                    if (result.status === 'SUCCESS' && result.data != null) {
                        //前端保存token
                        localStorage.setItem("user_token",result.data);
                        //跳转
                        location.href = "client.html";
                    }else {
                        alert(result.error)
                    }
                }
            })
        }
        //注册
        function register() {
            location.href = "register.html";
        }
    </script>
</body>
</html>